﻿@using Webdiyer.WebControls.Mvc;
@model PagedList<Magicodes.WeiChat.Data.Models.WeiChat.WeiChat_MessagesTemplate>

@{
    ViewBag.Title = "模板管理";
}

<div class="row wrapper border-bottom white-bg page-heading">
    <div class="col-lg-9">
        <h2>@ViewBag.Title</h2>
        <ol class="breadcrumb">
            <li>
                <a href="/">主页</a>
            </li>
            <li class="active">
                <strong>@ViewBag.Title</strong>
            </li>
        </ol>
    </div>
</div>

<div class="wrapper wrapper-content animated fadeInRight">
    <div class="row">
        <div class="col-lg-12">
            <div class="ibox float-e-margins">
                <div class="ibox-content">
                    <hr style="margin:2px 2px 10px 2px;" />
                    <div class="row">
                        <div class="col-sm-3">
                            @using (Html.BeginForm("Index", @Request.RequestContext.RouteData.GetRequiredString("controller"), FormMethod.Get))
                            {
                                <div class="input-group">
                                    @Html.TextBox("q", ViewBag.q as string, new { @placeholder = "请输入关键字", @class = "input-sm form-control" })
                                    <span class="input-group-btn">
                                        <button type="submit" class="btn btn-sm btn-primary"><i class="fa fa-search"></i>&nbsp;搜索</button>
                                    </span>
                                </div>
                            }
                        </div>
                        <a class="btn btn-primary btn-sm" href="@Url.Action("Create")" id="btnAdd"><i class="fa fa-plus"></i>&nbsp;新建</a>
                        <a class="btn btn-warning btn-sm" id="btnDelete" data-action="Delete" data-comfirmmessage="确定删除所选内容么？"><i class="fa fa-remove"></i>&nbsp;批量删除</a>
                        <a class="btn btn-info btn-sm ladda-button loadingButton" data-style="expand-right" data-ajaxurl="/api/Tasks/StartTenantTask/SyncMessagesTemplatesTask" data-notify="同步任务已触发，请关注右上角的通知信息！"><i class="fa fa-circle-o"></i>&nbsp;全量同步</a>
                    </div>
                    <div>
                        <table class="table table-striped table-bordered table-hover" style="overflow-x:scroll">
                            <tr>
                                <th>
                                    <input type="checkbox" name="checkAll" id="chkCheckAll" class="i-checks" />
                                </th>
                                <th>
                                    @Html.DisplayNameFor(model => model.ShortNo)
                                </th>
                                <th>
                                    @Html.DisplayNameFor(model => model.TemplateNo)
                                </th>
                                <th>
                                    @Html.DisplayNameFor(model => model.Title)
                                </th>
                                <th>
                                    @Html.DisplayNameFor(model => model.OneIndustry)
                                </th>
                                <th>
                                    @Html.DisplayNameFor(model => model.TwoIndustry)
                                </th>
                                <th>
                                    @Html.DisplayNameFor(model => model.Content)
                                </th>
                                <th>
                                    @Html.DisplayNameFor(model => model.Demo)
                                </th>
                                <th></th>
                            </tr>

                            @foreach (var item in Model)
                            {
                                <tr>
                                    <td>
                                        <input type="checkbox" name="ids" class="i-checks" value="@(item.Id)" />
                                    </td>
                                    <td>
                                        @Html.DisplayFor(modelItem => item.ShortNo)
                                    </td>
                                    <td>
                                        @Html.DisplayFor(modelItem => item.TemplateNo)
                                    </td>
                                    <td>
                                        @Html.DisplayFor(modelItem => item.Title)
                                    </td>
                                    <td>
                                        @Html.DisplayFor(modelItem => item.OneIndustry)
                                    </td>
                                    <td>
                                        @Html.DisplayFor(modelItem => item.TwoIndustry)
                                    </td>
                                    <td>
                                        @Html.Raw(item.Content.Replace("\n", "<br>"))
                                    </td>
                                    <td>
                                        @Html.Raw(item.Demo.Replace("\n", "<br>"))
                                    </td>
                                    <td>
                                        <div class="btn-group">
                                            <a href="@Url.Action("Details", new { id = item.Id })" class="btn btn-white">查看</a>

                                            <a class="btn btn-white" href="javascript:void(0)" data-title="发送模板消息" data-url="@Url.Action("Send", new { id = item.Id })" data-clicktype="modal">发送</a>
                                            <a class="btn btn-white" href="javascript:void(0)" data-title="发送日志" data-url="@Url.Action("Index", "WeiChat_MessagesTemplateSendLog", new { templateNo = item.Id })" data-clicktype="modal">日志</a>
                                            <button data-toggle="dropdown" class="btn btn-white dropdown-toggle">更多操作 <span class="caret"></span></button>
                                            <ul class="dropdown-menu">
                                                <li>@Html.ActionLink("编辑", "Edit", new { id = item.Id })</li>
                                                <li>@Html.ActionLink("删除", "Delete", new { id = item.Id })</li>
                                                @*分割线*@
                                                @*<li class="divider"></li>*@
                                            </ul>
                                        </div>
                                    </td>
                                </tr>
                            }
                        </table>
                    </div>
                    <div class="row">
                        @Html.Partial("_BootStrapPager", Model)
                    </div>
                </div>
            </div>
        </div>
    </div>
</div>
@section Styles {
    @Styles.Render("~/Content/plugins/iCheck/iCheckStyles")
    @Styles.Render("~/plugins/laddaStyles")
}
@section Scripts {
    @Scripts.Render("~/plugins/iCheck")
    @Scripts.Render("~/plugins/ladda")
    <script type="text/javascript">
        $(function () {
            mwc.bs.init({ loadingButton: true });
        });
    </script>
}
